package primalgorithms.other;

public class _06MissingNumber {
    public static int missingNumber(int[] nums) {
        //nums里面有n个数字，代表从0 ~ n共有n+1个数字，所以必有一个缺失
        int len = nums.length;
        boolean[] ifExit = new boolean[len+1];
        for (int i = 0;i < len;i++){
            ifExit[nums[i]] = true;
        }
        for (int i = 0;i < len+1;i++){
            if (!ifExit[i]){
                return i;
            }
        }
        return 0;
    }
}
